import json
import jieba
import jieba.analyse
path = "data2.json"
f = open(path,'r',encoding='utf-8')
data = json.load(f)
write_data = []
for item in data:
    des = item["name"]+item["description"]
    #words = jieba.lcut(des)
    #print(words)
    tags = jieba.analyse.extract_tags(des, topK=3)
    #print(tags)
    temp = item
    temp["keywords"] = tags
    write_data.append(temp)


with open("data.json","w", encoding='utf-8') as fp:
    json_str = json.dump(write_data, fp, ensure_ascii=False)
